#include "stdafx.h"
#include "xParticleEffectPlug.h"


namespace XE
{

	const xString xLineForceEffect::EffectType="LineForceEffect";

	const xString xLineForceEffectFactory::EffectType="LineForceEffect";

	xLineForceEffect::xLineForceEffect(const xString& name,xParticleTemplate * pParent)
		:xParticleEffect(name,pParent),m_Dir(0.0f,0.0f,0.0f),m_Power(0.0f)
	{
		AddPropertyFun("Dir",static_cast<GetPropertyFun>(&xLineForceEffect::GetDir),\
			static_cast<SetPropertyFun>(&xLineForceEffect::SetDir));

		AddPropertyFun("Power",static_cast<GetPropertyFun>(&xLineForceEffect::GetPower),\
			static_cast<SetPropertyFun>(&xLineForceEffect::SetPower));

	}

	xLineForceEffect::~xLineForceEffect()
	{

	}

	void xLineForceEffect::clone(xParticleEffect* pTarget)
	{
		xParticleEffect::clone(pTarget);
		m_Dir = static_cast<xLineForceEffect*>(pTarget)->m_Dir;
		m_Power = static_cast<xLineForceEffect*>(pTarget)->m_Power;


	}

	void xLineForceEffect::EffectParticle( xParticleSystemInstance* pParticle,WORD time)
	{
		
	   ParticleIterator it =  pParticle->GetActiveParticleIterator();
	   while(it.hasMoreElements())
	   {
		   xParticle* pPara = it.getNext();
		   pPara->m_Direction+=m_Dir*0.01;//*m_Power;
		 //  pPara->m_Direction/=2.0f;
	   }

		
		return ;

	}



	void xLineForceEffect::SetDir(const xString& dir)
	{
		m_Dir = xHelp::StringToVector3(dir);
	}
	void xLineForceEffect::GetDir(xString& dir)
	{
		dir =xHelp::Vector3ToString(m_Dir);
	}

	void xLineForceEffect::SetPower(const xString& power)
	{
		m_Power =xHelp::StringTofloat(power);
	}
	void xLineForceEffect::GetPower(xString& power)
	{ 
		power = xHelp::floatToString(m_Power);
	}



}